//
//  GFFootmarkTableViewCell.m
//  GoodFood
//
//  Created by dllo on 15/11/3.
//  Copyright © 2015年 荣伟峰. All rights reserved.
//

#import "GFFootmarkTableViewCell.h"

@interface GFFootmarkTableViewCell ()

@property (nonatomic, strong) UIImageView *userImage;
@property (nonatomic, strong) UILabel *foodNameLabel;
@property (nonatomic, strong) UILabel *placeLabel;
@property (nonatomic, strong) UILabel *timeLabel;

@end

@implementation GFFootmarkTableViewCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        
        self.userImage = [[UIImageView alloc] init];
        [self.contentView addSubview:self.userImage];
        
        self.foodNameLabel = [[UILabel alloc] init];
        [self.contentView addSubview:self.foodNameLabel];
        
        self.placeLabel = [[UILabel alloc] init];
        [self.contentView addSubview:self.placeLabel];
        
        self.timeLabel = [[UILabel alloc] init];
        [self.contentView addSubview:self.timeLabel];
        
    }
    return self;
}

-(void)layoutSubviews {
    
    [super layoutSubviews];
    
    self.userImage.frame = CGRectMake(10, 10, ScreenWidth / 5, ScreenWidth / 5);
    
    self.foodNameLabel.frame = CGRectMake(10 + ScreenWidth / 5 + 10, 10, ScreenWidth - 10 + ScreenWidth / 5 + 10, ScreenWidth / 15);
    
    self.placeLabel.frame = CGRectMake(10 + ScreenWidth / 5 + 10, 10 + ScreenWidth / 15, ScreenWidth - 10 + ScreenWidth / 5 + 10, ScreenWidth / 15);
    
    self.timeLabel.frame = CGRectMake(10 + ScreenWidth / 5 + 10, 10 + ScreenWidth / 7.5, ScreenWidth - 10 + ScreenWidth / 5 + 10, ScreenWidth / 15);
    
}

-(void)setTempDic:(NSDictionary *)tempDic {
    
    if (_tempDic != tempDic) {
        _tempDic = tempDic;
    }
    
    [self.userImage setImageWithURL:[NSURL URLWithString:tempDic[@"picture_url"]] placeholderImage:nil];
    
    self.foodNameLabel.text = tempDic[@"food_name"];
    
    self.placeLabel.text = [NSString stringWithFormat:@"@%@", tempDic[@"place_name"]];
    
    NSArray *timeArr = [tempDic[@"publish_time"] componentsSeparatedByString:@" "];
    self.timeLabel.text = timeArr[0];
    
}

- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
